package #PACKAGE#;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import #MODEL_PKG#.QueryCondition;

import #MODEL_PKG#.#CLASSNAME#;
import #MODEL_PKG#.Pager;
import #BASE_PKG#BaseAction;
import #SERVICE_PKG#.#CLASSNAME#Service;

@Controller
@Scope("prototype")
@Component("#LOWER_CASENAME#Action")
@ParentPackage("json-default")
@Namespace(value = "/action/#LOWER_CASENAME#")
public class #CLASSNAME#Action extends BaseAction {

    private static final long serialVersionUID = #UID#L;
    private Pager<#CLASSNAME#> pager;
    @Resource(name = "#LOWER_CASENAME#Service")
    protected #CLASSNAME#Service #LOWER_CASENAME#Service;

    @Override
    @Action(value = "get#CLASSNAME#s", results = {
        @Result(name = "success", type = "json")})
    public String execute() throws Exception {
    	pager = #LOWER_CASENAME#Service.findAll(ascProperty, isAsc, start, limit);
        return SUCCESS;
    }
    
    @Action(value = "findLike", results = { @Result(name = "success", type = "json") })
	public String findLike() throws Exception {
		List<QueryCondition> entities = new ArrayList<QueryCondition>(); 
		pager = #LOWER_CASENAME#Service.findAll(ascProperty, isAsc,start, limit, entities);
		return SUCCESS;
	}

    public Pager<#CLASSNAME#> getPager() {
		return pager;
	}

	public void setPager(Pager<#CLASSNAME#> pager) {
		this.pager = pager;
	}
}